<script type="text/javascript">
 $(function() {
	$( "#thongke_dt_from" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		}).change(function(){
			
		});
	$( "#thongke_dt_to" ).datepicker({
			showOn: "button",
			changeYear:true,
			changeMonth:true,
			buttonImage: "<?php echo base_url();?>resources/images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: 'dd/mm/yy'
		}).change(function(){
			
	});
 });
 
</script>
<style type="text/css">
	ul#tongketul{
		list-style-image:url('<?php echo base_url()?>resources/images/square.gif');
		float:left;
		margin-left:18px;
	}	
	#content{
		width: 805px;
	}
	#lietke{
		float:left;
		clear:both;
		padding-top:5px;
	}
	#thongke_dt_from,#thongke_dt_to{
		background-color: #DDDDDD;
		border: medium none;
		margin-left: 10px;
		padding: 3px;
	}
	#thongke_dt_from{margin-right:0px;}
	#hr{
		background-color: #565656;
		height:1px;width:100%;margin-top:10px;
		float:left;clear:both;
	}
	#btnGo{
		background: transparent url(<?php echo base_url()?>resources/images/btn.png) no-repeat;width:73px;height:27px;
		border: medium none;
		margin-left: 10px;cursor:pointer;
	}
	#content-left{
		background: transparent url(<?php echo base_url()?>resources/images/bg-tk-l.png) no-repeat;
		width:180px;height:396px;
		float:left;clear:both;margin-top:60px;
	}
	.container{
		margin-bottom:0px;
	}
	
</style>
	<div id="content"> <!-- content -->
		<h1>Tong ket thu</h1>
		<ul id="tongketul">
			<li>Tong ket cuoi thang</li>
		</ul>
		<div id="lietke">
			<?php echo form_open(current_url()); ?>	
	<span style="float:left;">Tu ngay<input id="thongke_dt_from" type="text" name="thongke_dt_from" value="<?php echo $time_from;?>"  /></span>
	<span style="float:left;margin-left:20px;">Den ngay<input id="thongke_dt_to" type="text" name="thongke_dt_to" value="<?php echo $time_to;?>"  /></span>
	<input id="btnGo" type="submit" value="Go" />
	<?php echo form_close(); ?>
		</div>
		<hr id="hr"/>
		<div id="content-left">
			<table class="tbContentLeft" border="0">
				<tr>
					<th colspan="3" class="c">So luong KH</th>
				</tr>
				<tr>
					<td class="c">Cu</td>
					<td class="c">Moi</td>
					<td class="c">TC</td>
				</tr>
				<tr>
					<td class="c"><?php echo $khcu;?></td>
					<td class="c"><?php echo $khmoi;?></td>
					<td class="c"><?php echo $khtc;?></td>
				</tr>
			</table>
			<table class="tbContentLeft" border="0">
				<tr>
					<th colspan="2" class="l" style="padding-left:30px;">So Thu</th>
				</tr>
				<tr>
					<td>Phieu moi</td>
					<td class="r"><?php echo $phieumoi;?></td>
				</tr>
				<tr>
					<td>Phieu cu</td>
					<td class="r"><?php echo $phieucu;?></td>
				</tr>
				<tr>
					<td>Tien mat</td>
					<td class="r"><?php echo formatcurrency($tienmat*1000);?></td>
				</tr>
				<tr>
					<td>Tips</td>
					<td class="r"><?php echo formatcurrency($tientip*1000);?></td>
				</tr>
				<tr>
					<td>% Dich Vu</td>
					<td class="r"><?php echo formatcurrency($percent_service*1000);?></td>
				</tr>
			</table>
			<table class="tbContentLeft" border="0" style="margin-top:-25px;">
				<tr>
					<th colspan="2">&nbsp;</th>
				</tr>
				<tr>
					<td>Tong ket:</td>
					<td class="r"><?php echo formatcurrency($tongket*1000);?></td>
				</tr>
			</table>
		</div>
		<div id="content-right" class="type1">
			<table border="0">
			   <tr border="0">
			   <!--
				   <th width="10%" style="border-right: solid 3px #fff;" class="first border-right">Muc</th>
				   <th width="30%" style="border-right: solid 3px #fff;" class="border-right">Dich vu</th>
				   <th width="5%" style="border-right: solid 3px #fff;" class="border-right">#KH</th>
				   <th width="15%" style="border-right: solid 3px #fff;" class="border-right">Gia Tri Dich Vu</th>
				   <th width="10%" style="border-right: solid 3px #fff;" class="border-right">Tips</th>
				   <th width="15%" style="border-right: solid 3px #fff;" class="border-right">% Dich Vu</th>
				   <th width="15%" class="last">Con lai</th>
				 -->
				   <?php
                foreach( $rules as $i ){
                    if( in_array( $i[ 'field_id' ], $master_limited  ) ){
						if(isset($i[ 'width' ]))
							$width = "width = '".$i[ 'width' ]."'";
						else
							$width = "";
                        echo "<th $width class='".$i['class']."' style='".$i['style']."'>". $i[ 'label' ]."</th>";
					}
                }
            ?>
			   <!--</tr>
			     <tr>
				   <td>Tam</td>
				   <td>Dich vu</td>
				   <td>1</td>
				   <td>200</td>
				   <td>2</td>
				   <td>3</td>
				   <td>100</td>
			   </tr>
			    <tr class="odd">
				   <td>Tam</td>
				   <td>Dich vu</td>
				   <td>2</td>
				   <td>200</td>
				    <td>2</td>
				   <td>3</td>
				   <td>100</td>
			   </tr>
			   -->
			   <?php
                for( $i = 0; $i < count( $results ); $i++ ){
                    echo "<tr>";
                            foreach( $rules as $item ){
                           	    if( $item[ 'field_id' ] != "Image_ID" && in_array( $item[ 'field_id' ], $master_limited ) ){	 
									if($i%2==1) $odd="odd"; else $odd="";
         			                echo "<td class='$odd'>";
									if($item[ 'control' ] == "time")
										echo date("d/m/y",$results[ $i ][ $item[ 'field_id' ] ]);
									else if($item[ 'control' ] == "vnd") 
										echo formatcurrency($results[ $i ][ $item[ 'field_id' ] ] * 1000);
									else if($item[ 'control' ] == "percent") 
										echo $results[ $i ][ $item[ 'field_id' ] ]."%";
									else echo $results[ $i ][ $item[ 'field_id' ] ];
            						echo "</td>";					
								}
                            }
                    echo "</tr>";
                }
            ?>
			<tr><td colspan="<?php echo count($rules);?>"><center><div class="pagination"><?php echo $this->pagination->create_links(); ?></div></center></td></tr>
			</table>
		</div> <!-- content right -->
		<div style="clear:both;">&nbsp;</div>
	</div><!--end content -->
</div><!-- end container -->